<!-- 股本结构 -->
<template>
  <div class="structure">
    <!-- 股本结构 -->
    <yn-com-comTitle name="股本结构"></yn-com-comTitle>
    <yn-stru-structureList :data="structure"></yn-stru-structureList>
    <!-- 股本结构变动 -->
    <yn-com-comTitle class="mt15" name="股本结构变动"></yn-com-comTitle>
    <yn-stru-change :data="change"></yn-stru-change>
    <!-- 限售解禁 -->
    <yn-com-comTitle class="mt15" name="限售解禁"></yn-com-comTitle>
    <yn-stru-limited :data="limited"></yn-stru-limited>
  </div>
</template>

<script>
import { getStructure } from "../script/api";

const handle = obj => {
  for (let key in obj) {
    for (let i = 1; i <= obj[key].length; i++) {
      obj[key][i - 1]._time = key;
      return { key: obj[key] };
    }
  }
};
export default {
  data() {
    return {
      change: {},
      limited: [],
      structure: []
    };
  },
  components: {},
  computed: {},
  mounted() {
    this.getStructure();
  },
  methods: {
    async getStructure() {
      const res = await getStructure();
      this.change = res.change ? handle(res.change) : {};
      this.limited = res.limited ? res.limited : [];
      this.structure = res.structure;
    }
  }
};
</script>
<style lang='scss' scoped>
</style>